package com.atguigu.tingshu.account.api;

import com.atguigu.tingshu.account.service.UserAccountService;
import com.atguigu.tingshu.common.anno.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Tag(name = "用户账户管理")
@RestController
@RequestMapping("api/account/userAccount")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserAccountApiController {

	@Autowired
	private UserAccountService userAccountService;


	@GuiguLogin
	@Operation(summary = "获取账号可用金额")
	@GetMapping("/getAvailableAmount")
	public Result<BigDecimal> getAvailableAmount() {
		return Result.ok(userAccountService.getAvailableAmount());
	}

	@GuiguLogin
	@Operation(summary = "检查与锁定账户金额-feign")
	@PostMapping("checkAndLock")
	public Result<AccountLockResultVo> checkAndLock(@RequestBody AccountLockVo  accountLockVo){
		AccountLockResultVo accountLockResultVo = userAccountService.checkAndLock(accountLockVo);
		return Result.ok(accountLockResultVo);

	}
}

